package com.fh.modules.ums.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fh.common.api.vo.Result;
import com.fh.common.aspect.annotation.AutoLog;
import com.fh.common.constant.CommonConstant;
import com.fh.common.query.QueryWrapperUtil;
import com.fh.common.util.ConvertUtils;
import com.fh.modules.ums.entity.UmsMemberPartnerInfo;
import com.fh.modules.ums.service.IUmsMemberPartnerInfoService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;

import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

 /**
 * @Title: Controller
 * @Description: 合伙人信息
 * @author： code generator
 * @date：   2019-09-25
 * @version： V1.0
 */
@RestController
@Slf4j
@Api("合伙人信息")
public class UmsMemberPartnerInfoController {
	@Autowired
	private IUmsMemberPartnerInfoService umsMemberPartnerInfoService;
	
	/**
	  * 分页列表查询
	 * @param umsMemberPartnerInfo
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@GetMapping(value = "/ums/umsMemberPartnerInfo/list")
	@ApiOperation("分页列表查询")
	@AutoLog(value="合伙人信息分页查询",logType=CommonConstant.LOG_TYPE_QUERY)
	public Result queryPageList(UmsMemberPartnerInfo umsMemberPartnerInfo,
									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
									  HttpServletRequest req) {
		QueryWrapper<UmsMemberPartnerInfo> queryWrapper = new QueryWrapper<UmsMemberPartnerInfo>();
		umsMemberPartnerInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
		QueryWrapperUtil.initQueryWrapper(queryWrapper, umsMemberPartnerInfo);
		Page<UmsMemberPartnerInfo> page = new Page<UmsMemberPartnerInfo>(pageNo, pageSize);
		IPage<UmsMemberPartnerInfo> pageList = umsMemberPartnerInfoService.page(page, queryWrapper);
		return Result.ok(pageList);
	}
	
	/**
	  *   添加
	 * @param umsMemberPartnerInfo
	 * @return
	 */
	@PostMapping(value = "/ums/umsMemberPartnerInfo/add")
	@ApiOperation("添加")
	@AutoLog("添加合伙人信息")
	public Result add(@RequestBody UmsMemberPartnerInfo umsMemberPartnerInfo) {
		umsMemberPartnerInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
		umsMemberPartnerInfoService.save(umsMemberPartnerInfo);
		return Result.ok("添加成功");
	}
	
	/**
	  *  编辑
	 * @param umsMemberPartnerInfo
	 * @return
	 */
	@PutMapping(value = "/ums/umsMemberPartnerInfo/edit")
	@ApiOperation("修改")
	@AutoLog("修改合伙人信息")
	public Result edit(@RequestBody UmsMemberPartnerInfo umsMemberPartnerInfo) {
		boolean ok = umsMemberPartnerInfoService.updateById(umsMemberPartnerInfo);
		return ok?Result.ok("修改成功"):Result.error("修改失败");
	}
	
	/**
	  *   通过id删除
	 * @param id
	 * @return
	 */
	@DeleteMapping(value = "/ums/umsMemberPartnerInfo/delete")
	@ApiOperation("通过id删除")
	@AutoLog("删除合伙人信息")
	public Result delete(@RequestParam(name="id",required=true) String id) {
		umsMemberPartnerInfoService.deleteEntityByDelFlag(id);
		return Result.ok("删除成功");
	}
	
	/**
	  *  批量删除
	 * @param ids
	 * @return
	 */
	@DeleteMapping(value = "/ums/umsMemberPartnerInfo/deleteBatch")
	@ApiOperation("批量删除")
	@AutoLog("批量删除合伙人信息")
	public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		umsMemberPartnerInfoService.deleteBatchEntityByDelFlag(ids);
		return Result.ok("批量删除成功");
	}
	
	/**
	  * 通过id查询
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/ums/umsMemberPartnerInfo/queryById")
	@ApiOperation("通过id查询")
	@AutoLog(value="合伙人信息通过id查询",logType=CommonConstant.LOG_TYPE_QUERY)
	public Result queryById(@RequestParam(name="id",required=true) String id) {
		UmsMemberPartnerInfo umsMemberPartnerInfo = umsMemberPartnerInfoService.getById(id);
		return Result.ok(umsMemberPartnerInfo);
	}


}
